package com.handinglian.ai.callin.controller;

import com.apidoc.annotation.Api;
import com.handinglian.ai.callin.dto.CallInDetailDto;
import com.handinglian.ai.callin.dto.CallInDto;
import com.handinglian.ai.callin.service.CallInService;
import com.handinglian.ai.common.dto.CommonPage;
import com.handinglian.ai.common.dto.ResultData;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api("呼入")
@RestController
@Slf4j
@RequestMapping("/callin")
public class CallInController {
    @Autowired
    private CallInService callInService;

    /**
     * 呼入列表
     */
    @GetMapping("/listPage")
    public ResultData<CommonPage<CallInDto>> listPage(String callerNo, String phoneStatus, String sortField, String sortOrder,
                                                      @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
                                                      @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) {
        CommonPage<CallInDto> commonPage = callInService.listPage(callerNo, phoneStatus, sortField, sortOrder, pageNum, pageSize);
        return ResultData.success(commonPage);
    }

    /**
     * 获取呼入详情
     */
    @GetMapping("/getDetail")
    public ResultData<CallInDetailDto> getDetail(String callid) {
        CallInDetailDto callInDetailDto = callInService.getDetail(callid);
        return ResultData.success(callInDetailDto);
    }
}
